﻿using System.Collections.Generic;

namespace AyuBookmark.Common.Models
{
    /// <summary>
    /// 分页结果封装
    /// </summary>
    public class PaginatedResult<T>
    {
        //    public IEnumerable<T> Items { get; set; }
        //    public int TotalCount { get; set; }
        //    public int PageIndex { get; set; }
        //    public int PageSize { get; set; }
        /// <summary>
        /// 当前页码
        /// </summary>
        public int PageIndex { get; set; }

        /// <summary>
        /// 每页记录数
        /// </summary>
        public int PageSize { get; set; }

        /// <summary>
        /// 总记录数
        /// </summary>
        public int TotalCount { get; set; }

        /// <summary>
        /// 总页数
        /// </summary>
        public int TotalPages => (int)Math.Ceiling(TotalCount / (double)PageSize);

        /// <summary>
        /// 当前页数据
        /// </summary>
        public IEnumerable<T> Items { get; set; } = new List<T>();

        /// <summary>
        /// 是否有上一页
        /// </summary>
        public bool HasPreviousPage => PageIndex > 1;

        /// <summary>
        /// 是否有下一页
        /// </summary>
        public bool HasNextPage => PageIndex < TotalPages;

    }
}